//
//  UIView+Common.m
//  ArtDog
//
//  Created by dllo on 16/9/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UIView+Common.h"
#import "NSString+Common.h"
#import "MineMainViewController.h"

@implementation UIView (Common)

- (UIViewController *)getVCRecently
{
    UIView *view = self;
    while (1) {
        if ([view.nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)view.nextResponder;
        } else {
            if ([view.nextResponder isEqual:view]) {
                return nil;
            }
            view = (UIView *)view.nextResponder;
        }
    }
    
}

- (BOOL)noLoginSkipLoginPage
{
    if ([[NSString getUserDefaultId]isEqualToString:@"0"]) {
        UIViewController *vc = [self getVCRecently];
        UINavigationController *mineNavi = vc.tabBarController.viewControllers[3];
        MineMainViewController *mineVC = mineNavi.viewControllers[0];
        mineVC.lastIndex = vc.tabBarController.selectedIndex;
        vc.tabBarController.selectedIndex = 3;
        return YES;
    }
    return NO;
}

- (UIView *)clickWhitespaceView
{
    UIViewController *vc = [self getVCRecently];
    UIView *view = [[UIView alloc]initWithFrame:vc.view.bounds];
    [vc.view addSubview:view];
    return view;
}

@end
